home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / convrtrs / gfxrippr.lha / GFXRipper / mon.doc < prev    next >
Encoding:
Text File  |  1993-05-05  |  42.8 KB  |  1,139 lines

  1.  
  2.                  Amiga Monitor v1.59 instructions
  3.                  ================================
  4.  
  5.   This is a machine code monitor/debugger program for the Amiga.
  6.   The first version was created over 3 years ago, and many of the
  7.   features and commands of the monitor were made similar to those
  8.   of the monitors available for the Commodore 64. However, because
  9.   the Amiga is a quite different machine many new commands and
  10.   features were needed. Later versions of the monitor add many more
  11.   useful features, as expressions and variables. This version is quite
  12.   close to an actual symbolic debugger as it can read symbol table
  13.   information from executable files and display them in disassembly
  14.   listings. It also has a built-in script language.
  15.  
  16.   The monitor can be started both from CLI and from workbench. If you
  17.   want to start the monitor from workbench, you must first make an icon
  18.   for it. (starting the monitor from workbench is not recommended,
  19.   because the  programs that are run under the control of the monitor
  20.   may require the CLI environment or else they may wait for workbench
  21.   startup message forever...but you can use IconX to start the monitor
  22.   from workbench as a CLI process)
  23.  
  24.   The monitor is re-entrant (pure) code and can be made resident
  25.   (for example, using the Workbench 1.3/2.0 resident command or ARP 1.3 ares)
  26.  
  27.  
  28.   Command line arguments
  29.   ----------------------
  30.  
  31.   options:
  32.    -w <window width>
  33.    -h <window height>
  34.    -o <options>                (see `Options Flags')
  35.    -s <initial-script-filename>        (see `Scripts')
  36.  
  37.   An optional filename can also be given in the command line.  The monitor
  38.   will try to load the named executable file immediately after starting.
  39.   The filename must be in quotes if it contains spaces. If there is anything
  40.   on the command line after the file name, that will be used as the command
  41.   line for the program loaded to the monitor (a0/d0 registers, see @-command)
  42.  
  43.   If a `+' character is used before the filename, the monitor tries to load
  44.   symbol information from the file (see also `l'-command).
  45.  
  46.   Using the monitor from a remote terminal
  47.   ----------------------------------------
  48.  
  49.   The monitor can be used from a terminal connected to the Amiga serial
  50.   port. If you want to do this, first set the correct baud rate and other
  51.   serial settings using the preferences program. Then mount AUX:
  52.   if necessary, and start a new CLI/Shell with the command NewShell AUX:
  53.   (or NewCLI AUX:). You get the normal CLI/Shell prompt to the terminal.
  54.   Now simply start the monitor by typing `mon' <cr> to the terminal
  55.   (do not `run' the monitor from the terminal; if you do it, the
  56.   monitor opens a window on the Amiga display). If the terminal is not
  57.   vt100/ansi compatible, you may need to use the `Dumb Terminal' option
  58.   flag (flag #3) to disable some features of the monitor (such as
  59.   command line editing and history, but you can still delete the last
  60.   character with backspace/delete). Easies way to do that is to start
  61.   the monitor with the command `mon -o4'.
  62.  
  63.  
  64.   Option flags
  65.   ------------
  66.  
  67.   Commands `opt +n' and `opt -n' where `n' is a number between 1 and 4
  68.   can be used to set and reset monitor option flags. Currently four
  69.   flags are implemented:
  70.  
  71.    - flag #1
  72.       Switches on the narrow disassembly output mode
  73.       (does not show the data as hex digits)
  74.  
  75.    - flag #2
  76.       Causes characters $a0-$ff to be considered printable in
  77.       `m' command memory dump (and `?' command ascii display)
  78.       (Note that this was changed in 1.42, previously they were
  79.       printable by default).
  80.  
  81.    - flag #3
  82.       This is the `Dumb terminal' mode flag. When this is set on,
  83.       the command line history and editing features of the monitor
  84.       are disabled, and the monitor does not use any vt100/ansi-
  85.       escape sequences.
  86.  
  87.    - flag #4
  88.       When this flag is set, the monitor echoes each command to its
  89.       output window/file before actually executing the commands.
  90.       This is mainly useful with scripts.
  91.  
  92.    - flag #5
  93.       Normally the monitor automatically resets the stack pointer
  94.       to point to the normal stack area if it originally was out
  95.       of range in the j/g/w/e/q-commands. This automatic stack reset
  96.       can be disabled with this option flag. This is useful when
  97.       debugging programs that allocate their own stacks and change
  98.       the stack pointer there. The stack pointer can be reset manually
  99.       with the rs-command.
  100.  
  101.   Command `opt' without parameters lists the current flag settins.
  102.   This includes a hexadecimal `flag value' that can be used on
  103.   the command line with the `-o' option to set initial flags when the
  104.   monitor is started (That flag value is simply a bit map of the option
  105.   flags, option #1 is bit #0).
  106.  
  107.  
  108.   Input line editing and command line history
  109.   -------------------------------------------
  110.  
  111.   You can edit the input lines by using the left/right cursor keys to move
  112.   left and right, backspace to delete the character before the cursor and
  113.   del to delete the character under the cursor. You can use the up/down
  114.   cursor keys to get the old command lines (the monitor remembers 10 last
  115.   command lines). Shift-cursor-up gets the last command and enters it
  116.   automatically (you don't need to press <CR>). In assembler mode you can
  117.   press Ctrl-E to edit the assembler instruction currently stored in that
  118.   address.
  119.  
  120.   These features are not available if the `Dumb terminal' mode is
  121.   selected. In that case the only editing function is deleting the
  122.   last character with backspace or delete key.
  123.  
  124.   Stopping the output
  125.   -------------------
  126.  
  127.   In most cases the output of the monitor can be suspended by pressing SPACE
  128.   or control-S and continued by pressing control-S or SPACE again.
  129.   To permanently stop the output, press Ctrl-C.
  130.  
  131.  
  132.   Numbers
  133.   -------
  134.  
  135.   Default number base is hexadecimal but it can be changed with the ba-
  136.   command (the argument of the ba-command is always decimal).
  137.  
  138.   the prefixes used to identify number bases are:
  139.    `$'   hexadecimal
  140.    `@'   octal
  141.    `%'   binary
  142.    `_'   decimal
  143.  
  144.   Numbers can also be entered as ASCII strings in single quotes, for example:
  145.    'FORM'  -->  hex 464f524d
  146.  
  147.   Note that `+' was the decimal prefix in older versions. Now it is `_'.
  148.  
  149.   Expressions
  150.   -----------
  151.  
  152.   The monitor accepts expressions in most places where you need a number.
  153.  
  154.   The calculator (`?') command allows you to directly display
  155.   values of expressions.
  156.  
  157.  
  158.   The following operators are available:
  159.  
  160.      ==  equality tese
  161.      !=  inequality test
  162.      <   less than                these tests return 1 if true and 0 if false
  163.      >   greater than             they are most useful in scripts
  164.      <=  less or equal than
  165.      >=  greater or equal than
  166.  
  167.      +   addition
  168.      -   subtraction
  169.      |   bitwise or
  170.      ^   bitwise exclusive or (xor)
  171.      &   bitwise and
  172.      *   multiplication
  173.      /   division (integer only, truncated)
  174.      %   modulo
  175.      <<  left shift
  176.      >>  right shift
  177.  
  178.   parenthesis can be used to group the operations in the expressions.
  179.  
  180.     `*'           represents the `current address'.
  181.  
  182.     [reg_name]    represents the value of register `reg_name'.
  183.  
  184.   All calculations are done in 32-bit integer arithmetic. No overflow
  185.   checking is done.
  186.  
  187.   Functions
  188.   ---------
  189.  
  190.   The expression parser currently accepts the following built-in functions:
  191.  
  192.    hunk(n)  --  start address of nth hunk of currently loaded seglist
  193.    hlen(n)  --  length of nth hunk of currently loaded seglist
  194.    hend(n)  --  end address of nth hunk of currently loaded seglist
  195.    nhunks   --  number of hunks in the currently loaded seglist
  196.    abs(x)   --  absolute value of a number  
  197.    peek(a)  --  8-bit contents of a memory location
  198.    peekw(a) --  16-bit contents of a memory location
  199.    peekl(a) --  32-bit contents of a memory location
  200.    avail(x) --  call AvailMem() with the argument x. for example
  201.         avail(0) returns total available memory,
  202.         avail(2) returns available chip memory
  203.         avail($20000) return largest available block.
  204.  
  205.   The following functions can be used to examine exec library, device,
  206.   resource, task and port lists. Note that the pointers returned by these
  207.   functions may become invalid any time if the library/device/task/port
  208.   is expunged/removed from the system.
  209.  
  210.   lib("libname.library")   --    returns base address of a named library or
  211.                 zero if not found. note that this does not
  212.                 try to load the library from disk, it
  213.                 only searches ExecBase->LibList.
  214.  
  215.   dev("devname.device")   --    returns base address of a named device or
  216.                 zero if not found. note that this does not
  217.                 try to load the device from disk, it
  218.                 only searches ExecBase->DeviceList.
  219.  
  220.   res("resname.resource") --    returns base address of a named resource or
  221.                 zero if not found.
  222.  
  223.   task("taskname")      --    returns pointer to named task or zero if
  224.                 not found.
  225.   task(number)          --    returns pointer to CLI process with the
  226.                 given number or zero if the CLI number
  227.                 is not in use.
  228.   task(0)          --    returns pointer to current task (the CLI
  229.                 process that runs the monitor)
  230.  
  231.   port("portname")      --    returns pointer to the public message port
  232.                 names "portname" or zero if no such port
  233.                 can be found.
  234.  
  235.   Function names are not case sensitive.
  236.  
  237.   Variables
  238.   ---------
  239.  
  240.   In addition to numbers and functions, variables can be used in expressions
  241.   if they have been previously defined. Variables are defined with the
  242.   set-command.  All variable values are 32-bit integers. Variable names can
  243.   contain alphanumeric characters and underscores (`_'), but they cannot
  244.   begin with a number. Variable names are case sensitive in this version.
  245.  
  246.   (There are some problems using variables with the assembler.
  247.   Especially variables with names starting with `a',`d' or `s' may
  248.   not be accepted in the assembler because it tries to interpret them
  249.   as register names. You can get around this by using expressions
  250.   like `0+variable')
  251.  
  252.   Byte strings
  253.   ------------
  254.  
  255.   Strings are used in the fill command, the hunt command, the modify memory
  256.   command and the assembler directive dc.b .
  257.  
  258.   Byte strings are series of bytes, represented by numbers or ASCII-
  259.   characters in single quotes or both together separated by commas.
  260.  
  261.   Note: the single quote itself may be included in a quoted string if it
  262.   is duplicated.
  263.    examples:
  264.     'this is a byte string'
  265.     12,34,56
  266.     ''''  -- this means one single quote
  267.     'both',$0A,'text',10,'and','numbers'
  268.  
  269.  
  270.   Special Note
  271.   ------------
  272.  
  273.   There is a problem with the walk (trace) command and several instructions
  274.   that cause processor exceptions. These instructions are chk, trap #n,
  275.   trapv and divu/divs (with divisions by zero). If you try to trace these
  276.   instructions, a trace-exception occurs in supervisor-mode, out of the
  277.   control of the monitor and you get a guru meditation alert with number
  278.   00000009. This problem was with the earlier monitor versions as well.
  279.  
  280.   Included with the monitor distribution is a program called patchtrace
  281.   that changes directly the processor hardware trace-exception vector to
  282.   point a new routine that removes the trap-trace problem.
  283.  
  284.   (The monitor does not support executing code in supervisor mode, so there
  285.   is not normally any reason to trace any of the instructions that can
  286.   cause problems. However, because you can accidentally cause the machine
  287.   to crash by tracing these instructions, the patchtrace-program
  288.   may be useful.)
  289.  
  290.   Stack usage
  291.   -----------
  292.  
  293.   The monitor allocates 2K of stack for its own use and the rest of
  294.   the stack can be used by the program being debugged. If you need
  295.   a larger stack, you can use the CLI `stack' command before you
  296.   start the monitor.
  297.  
  298.  
  299.   File/directory names
  300.   --------------------
  301.  
  302.   When the monitor requires a file or directory name or the device name
  303.   for the `dev'-command, the name must be in double quotes if it contains
  304.   spaces. This has been changed from the previous versions. Also, some
  305.   escape processing is now done to the filename strings and the arguments
  306.   of the echo-command. See the entry for echo-command for details.
  307.  
  308.  
  309.   The following commands are available in the monitor
  310.   ---------------------------------------------------
  311.  
  312. h or the HELP key on the keyboard
  313.  displays a list of commands.
  314.  
  315. i -- Info
  316.  displays a small info-message.
  317.  
  318. o -- Redirect output
  319.  usage:
  320.   o name -- redirects monitor output to file or device `name'
  321.   o      -- returns to normal, output comes to the monitor window
  322.  For example, to send the output to printer use `o PRT:'.
  323.  If the file specified in the `o'-command already exists, the monitor
  324.  output will be appended to the end of the file.
  325.  
  326. ? [expr]  --  Calculator
  327.   Displays the value of the expression in hex, decimal, octal, binary
  328.   and ASCII characters.  If the number is negative, displays it as signed
  329.   and unsigned.
  330.  
  331. set [var[=expr]] -- Set/show variables
  332.   The set-command without parameters displays the values of all currently
  333.   defined variables. The form `set var=expr' sets the value of `var' to
  334.   the value of the expression. `set var' removes the definition of `var'.
  335.  
  336. cv -- Clear all variables
  337.   Asks if you really want to do it, answer `y' to clear them.
  338.  
  339. ba [num]  --  Set/show current number base
  340.   ba without parameters displays the current number base. ba [num] sets
  341.   the base to [num] which is always decimal. this is the default base
  342.   used in number input if no base prefix is specified. initially it is 16
  343.   (hexadecimal).
  344.  
  345. mi [addr] -- Display information about memory locations
  346.   The mi-command tells you if the address `addr' is in the system memory
  347.   list, is it allocated or not and is it inside any of the hunks
  348.   of the currently loaded segment.
  349.  
  350. m -- Display memory in hex and ASCII
  351.  Usage:
  352.   m                   -- display 20 lines from current address
  353.   m <addr>            -- display 20 lines from <addr>
  354.   m <addr> <end-addr> -- display from <addr> to <end-addr>
  355.  
  356.  If the memory display was started inside a hunk of currently loaded executable,
  357.  it automatically stops at the end of that hunk.
  358.  
  359. mf -- Formatted memory display
  360.  Usage:
  361.   mf "formatstring"
  362.   mf <addr> "formatstring"
  363.   mf <addr> <endaddr> "formatstring"
  364.  
  365.   This command displays memory in user-specified format. The format string
  366.   can contain normal text that is printed directly and c-printf-style
  367.   format specifiers. The following format specifiers are currently supported:
  368.     %b  -- hex byte
  369.     %w  -- hex word
  370.     %l  -- hex longword
  371.     %db -- decimal byte
  372.     %dw -- decimal word
  373.     %dl -- decimal longword
  374.     %a  -- current address (in hex)
  375.     %c  -- ASCII character (printable ones only, others show as `.')
  376.     %s  -- string (longword pointer to a NUL-terminated string)
  377.     %x  -- BCPL string (longword pointer to a string with length byte)
  378.            (non-printable characters in strings are printed as `.'
  379.             Strings longer than 100 characters are truncated)
  380.   The escape sequences described in the `echo'-command entry
  381.   can also be used in the format string.
  382.  
  383.   Note1: words and longs that are displayed must be at even addresses. If the
  384.   current address os odd when a word or longword value is going to be displayed,
  385.   the address is incremented to the next even address and an asterisk is
  386.   printed as a warning to the user.
  387.  
  388.   Note2: a space is required between this command and its arguments.
  389.  
  390. : -- Modify memory
  391.  Usage:
  392.   : <addr> <string>
  393.   Puts the <string> in memory at <addr>
  394.   This can also be done with the command `a <addr> dc.b <string>'
  395.   (but then <addr> must be even)
  396.  
  397. f -- Fill memory with a byte or a string of bytes
  398.  Usage:
  399.   f <start-addr> <end-addr> <byte>   ;fills with <byte>
  400.   f <start-addr> <end-addr> <string> ;fills with the string
  401.  Example:
  402.   f $60000 $601FF $4E,$71 fills from $60000 to $601FF with NOP-instruction
  403.  
  404. t -- Transfer (move) memory
  405.  Usage:
  406.   t <start-addr> <end-addr> <destination-addr>
  407.  The command works correctly even if the source and destination memory
  408.  blocks overlap. (if destination is at a higher address than source,
  409.   the block is moved backwards, starting at the end)
  410.  
  411. h -- Hunt (find) string in memory
  412.  Usage:
  413.   h <start-addr> <end-addr> <string>
  414.   Displays all addresses in the range <start-addr>..<end-addr>
  415.   where the <string> is found.
  416.  
  417. c -- Compare memory
  418.  Usage:
  419.   c <start-addr> <end-addr> <string>
  420.   Displays all addresses in the range <start-addr>..<end-addr>
  421.   where is corresponding byte in the destination block is different from
  422.   the source.
  423.  
  424. a -- Assemble
  425.  usage:
  426.   a         : assemble to the current address
  427.   a <addr>  : assemble to <addr>
  428.   a <addr> <instruction> : assemble <instruction> at <addr>
  429.   After assembling an instruction the monitor prompts with the address of
  430.   the location following the instruction just assembled and waits a new
  431.   instruction to be entered. To exit this mode, simply press <CR> without
  432.   entering an instruction. To edit an existing instruction, press Ctrl-E when
  433.   the monitor is waiting an assembler instruction.
  434.  
  435.    The assembler understands all the normal 68000 instructions and also
  436.   the `pseudo-instructions' dc.b, dc.w and dc.l, which can be used to
  437.   directly put data in memory.
  438.  
  439.  Some notes about using the assembler:
  440.  -------------------------------------
  441.    When entering assembler instructions which have an implicit size, no
  442.    size specifier is allowed in the monitor assembler. These instructions
  443.    are for example btst, bchg, bclr, btst, lea, move to/from sr/ccr/usp,
  444.    andi/ori/eori #data,sr/ccr Scc (set according to condition),
  445.    abcd/sbcd/nbcd and shifts with memory operands.
  446.  
  447.    Instructions that can have different sizes must have the size specifier,
  448.    there is no `default size' (normal assemblers use a default size of word.
  449.    The omission of default size is intentional, because it is so easy to
  450.    forget the size specifier when you really don't mean the size to be word).
  451.  
  452.    Branch instructions with no size specifier or the .l-specifier assemble
  453.    to normal (16-bit offset) branches, if given the .s-size specifier they
  454.    assemble to the short form (8-bit offset). The dbxx-(decrement and branch)
  455.    -instructions allow no size specifier.
  456.  
  457.    The assembler converts add/sub/and/or/eor with immediate data source
  458.    automatically to adda/addi/subi/andi/eori. It does not convert move or
  459.    add/sub to the quick form nor does it convert branches automatically to
  460.    the short form. You must specify those yourself (so you must use the
  461.    moveq/addq/subq- instructions or specify the size .s to branches
  462.    as noted above). Also cmp-memory instruction must be entered as cmpm,
  463.    the assembler does not convert cmp (an)+,(an)+ to cmpm.
  464.  
  465.    The above conversion rules do not apply to andi/ori/eori with status
  466.    register or condition code register. In these cases you must enter the
  467.    instruction as andi/ori/eori (don't leave the `i' out). Also, you
  468.    can't enter any size specifier in this case.
  469.  
  470.   (In fact I want to make the assembler more flexible than it currently is,
  471.   but that is not an easy task...maybe in some future version...)
  472.  
  473. d -- Disassemble
  474.  Usage:
  475.   d                   -- disassemble 20 lines from current address
  476.   d <addr>            -- disassemble 20 lines from <addr>
  477.   d <addr> <end-addr> -- disassemble from <addr> to <end-addr>
  478.  
  479.  If the disassembly was started inside a hunk of currently loaded executable,
  480.  it automatically stops at the end of that hunk.
  481.  
  482. r -- Show or change registers
  483.  Usage:
  484.   r        -- displays all registers
  485.   r <reg>=<number> or
  486.   r <reg> <number> -- puts the value <number> into <reg>
  487.    examples:
  488.     r D0=0
  489.     r A5 $60000
  490.  
  491. b -- Set breakpoints
  492.  Usage:
  493.   b <addr> [count] -- sets a breakpoint to <addr> with optional count
  494.    Breakpoints are implemented by putting an illegal opcode ($4AFC) in the
  495.   breakpoint locations when a G or J command is given. After returning to
  496.   the monitor the original contents of the breakpoints are restored. This
  497.   means that you can not put breakpoints to ROM (but you can trace ROM code).
  498.  
  499.   If no count is specified, default count of one is used. That means that
  500.   the execution of a program stops and control returns to the monitor
  501.   immediately when the breakpoint is encountered. If the breakpoint has
  502.   a count that is greater than one, then control returns to the monitor
  503.   when the breakpoint has been `hit' as many times as the count is.
  504.  
  505.   Breakpoint counts do not work with the `q' (quicktrace) command.
  506.  
  507.  
  508. br -- Remove breakpoints
  509.  usage:
  510.   br <addr> -- removes the breakpoint at <addr>
  511.   br all    -- removes all breakpoints
  512.  
  513. bl -- List breakpoints
  514.  Usage:
  515.   bl -- display a list of all breakpoints.
  516.  
  517. The g, j, w, q and e-commands use the current program counter value
  518. (displayed with the r-command) if you don't give them an address.
  519. The stack pointer is reset and a return address to the monitor is
  520. put in the stack if the stack pointer is out of range. This automatic
  521. stack pointer reset can be disabled with option flag #5. The stack
  522. pointer can be manually reset with the 'rs'-command.
  523.  
  524. g [addr] -- Go (execute machine code)
  525.  
  526. j [addr] -- Jump to subroutine
  527.  As g-command but pushes return address first. this return address will
  528.  give control back to the monitor when rts-instructions is executed.
  529.  
  530. w [addr] -- Walk (single step trace)
  531.  This single steps code using the 68000 processor built-in trace mode.
  532.  It works even with ROM code (but the e-command doesn't).
  533.  
  534.  (This command does not activate breakpoints)
  535.  
  536. e [addr] -- Extended trace (execute with temporary breakpoint)
  537.  This command allows you to execute subroutine calls in full speed
  538.  when tracing and you don't need to manually place a breakpoint after
  539.  the calls. when the e-command is executed, a temporary breakpoint is
  540.  placed in the location after the instruction to be executed. this break-
  541.  point is automatically removed after the control returns to the monitor.
  542.  
  543.  The e-command can be used instead of the w-command to trace most of the
  544.  instructions, but it is recommended that you use the w-command for
  545.  tracing and when tracing code until you get to a subroutine call
  546.  instruction. then enter the e-command and the subroutine is executed
  547.  normally, but after that the monitor interrupts execution to the
  548.  invisible breakpoint.
  549.  
  550.  Note that if you use the e-command in an address that contains a flow-
  551.  control instruction, the code flow may never come to the temporary
  552.  breakpoint. Normally it is better to trace using the w-instruction,
  553.  but for example, system calls cannot always be traced, and even if
  554.  they can, you most probably don't want to do it. In previous versions
  555.  of the monitor you had to manually insert a breakpoint after the call
  556.  and use the g-command. Now you can simply use the e-command.
  557.  
  558. q [addr] -- QuickTrace (execute until flow-control instruction)
  559.  This command executes code one instruction at time (in the 68000 trace mode)
  560.  until it encounters a program flow control instruction (jump, branch,
  561.  subroutine call or return, trap).
  562.  
  563. z -- skip current instruction
  564.  This command can be used to advance the PC register over one instruction.
  565.  Note that this does not actually execute or trace code, it only changes
  566.  the monitor internal register values. An address can also be given as
  567.  a parameter to this command but it is normally not useful (the current
  568.  PC value will normally be used).
  569.  
  570. Note: there is no easy way to run BCPL programs (CLI commands) or other
  571. programs that use the internal BCPL library from the monitor.
  572.  
  573. @ -- Enter command line
  574.  Usage:
  575.   @ [command line]. If you don't specify a command line (enter only @<cr>)
  576.   then the monitor will prompt for command line. The command line will
  577.   be put in a special memory area and the register a0 will contain pointer
  578.   to the string and d0 will contain length of the string (with a linefeed
  579.   appended to end of it). If you want an empty command line, enter the
  580.   @-command without parameters and press return on the `Cmdline>'-prompt.
  581.   The purpose of this command is to specify a command line for the program
  582.   that you are running from the monitor. If you start the monitor with a
  583.   filename, anything after the filename is automatically used as the
  584.   command line.
  585.  
  586.   Note that the command line arguments set by this command (or monitor
  587.   command line) don't work with programs that use the AmigaDOS 2.0
  588.   ReadArgs() function. That function reads the command file from
  589.   the buffer of the standard input file handle.
  590.  
  591.  
  592. l -- Load segment
  593.  Usage:
  594.   l [+] <name> -- loads the executable file <name> in memory and displays
  595.     the starting address of the first hunk, also sets PC to this address.
  596.    only one executable file be loaded at the same time. Before loading a
  597.   new file you must unload the old file with the u-command.  To display
  598.   the starting & ending addresses of all the hunks in the file, use the
  599.   sl-command.
  600.  
  601.   Command `l + <name>' loads symbol table and hunk type information in
  602.   addition to the actual file hunks. Those symbols are like the variables
  603.   defined by `set' command, but they also have a hunk number associated with
  604.   them (it shows in square brackets in the `set' listing). Also, the symbols
  605.   are automatically removed when the file is unloaded with the `u'-command.
  606.  
  607.   The command line (see @-command) is initialized as empty when this
  608.   command is executed.
  609.  
  610.   Overlays are not supported.
  611.  
  612. u -- Unload segment
  613.  Usage:
  614.   u  -- unload the currently loaded executable file.
  615.         symbol information loaded by `l +' is removed by this command.
  616.  
  617. sl -- Segment list
  618.  Usage:
  619.   sl -- displays the starting & ending addresses and length of each hunk
  620.   of the currently loaded file. If the `l +' command has been used to
  621.   load the file, also the type of each hunk is displayed (including chip/fast
  622.   memory types and data/bss byte counts of split data/bss hunks).
  623.  
  624. rb -- set base address for address register relative symbols
  625.  Usage:
  626.   rb addr  --    sets base address of a4-relative addressing to addr. typically
  627.                  this is in the beginning of the data hunk of a program with
  628.                  programs compiled with Lattice/SAS C.
  629.   rb addr reg -- as above but allows selection of address register
  630.                  other than a4.
  631.   rb 0     --    removes the base address setting.
  632.   rb       --    displays current base address setting.
  633.  
  634.   When the base address setting is active, the disassembler will check all
  635.   xx(a4) (or other addr reg, if selected) addressing modes and if
  636.   baseaddr + offset equals a symbol, the symbol is displayed.
  637.  
  638. ( -- Allocate memory
  639.  Usage:
  640.   ( <length>        -- allocate <length> bytes any type of memory
  641.   ( <length> C      -- allocate <length> bytes of chip memory
  642.   Displays the start & end addresses of the allocated memory block.
  643.  
  644. & -- Allocate absolute memory location
  645.  Usage:
  646.   & <addr> <length> -- allocate <length> bytes at <addr>
  647.  
  648. ) -- Free memory
  649.  Usage:
  650.   ) <addr> -- frees the memory block starting at <addr>
  651.   ) all    -- frees all the memory allocated with the (- and &-commands
  652.  
  653. sm -- Show allocated memory
  654.  Usage:
  655.   sm -- display all memory blocks allocated with the (- and &-commands
  656.  
  657. [  -- Read file
  658.  Usage:
  659.   [ <addr> <name> -- reads the file <name> to memory starting at <addr>
  660.  
  661. ]  -- Write file
  662.  Usage:
  663.   ] <addr> <length> <name> -- creates a file named <name> and writes <length>
  664.  bytes of memory starting at <addr> to the file.
  665.  
  666. dev -- set/show current disk device
  667.  Usage:
  668.   dev  --  show current disk device
  669.   dev devname -- set current disk device
  670.  
  671.  devname is an exec device name, given without quotes and with the `.device'-
  672.  suffix. for example, if you have a 2090 hd controller, you can
  673.  set it as the default disk device with the command: dev hddisk.device
  674.  Note that the disk read/write commands work in the exec device level and
  675.  know nothing about hard disk partitions. Be careful if you use the monitor
  676.  to edit hard disk sectors! Note also that actual disk IO buffers used by
  677.  the monitor are always in chip memory.
  678.  
  679.  The current disk device is used by the `<' and `>'-commands.  Previous
  680.  versions of the monitor had them hardwired to use trackdisk.device.
  681.  
  682. <  -- Read disk sectors
  683.  Usage:
  684.   < <addr> <unit> <start-sector> <number-of-sectors>
  685.  Reads <number-of-sectors> sectors from the disk in unit <unit> to memory
  686.  starting at <addr>. <unit> is the unit number to be used in OpenDevice().
  687.  with the default device (trackdisk.device) units 0..3 correspond DOS
  688.  devices DF0: -- DF3:
  689.  
  690.  the read destination address does not need to be in chip memory.
  691.  
  692. >  -- Write disk sectors
  693.  Usage:
  694.   > <addr> <unit> <start-sector> <number-of-sectors>
  695.  Writes <number-of-sectors> sectors to the disk in unit <unit> from memory
  696.  starting at <addr>. <unit> is the unit number to be used in OpenDevice().
  697.  with the default device (trackdisk.device) units 0..3 correspond DOS
  698.  devices DF0: -- DF3:
  699.  
  700.  the write source address does not need to be in chip memory.
  701.  
  702. =  -- Corrects a disk block checksum
  703.  Usage:
  704.   = <addr> -- if there is a DOS-format disk block read into memory at <addr>,
  705.  calculates the correct checksum for the block and stores it in the block.
  706.  Displays old and new checksums. This command is useful if use use the
  707.  monitor as a disk editor. Addr must be even.
  708.  
  709.  Extended usage: = <addr> <len> <offs>
  710.  where <len> is block length to be checksummed and <offs> is the offset
  711.  of the checksum longword from the start of the block. The checksum is
  712.  calculated to that the sum of the longwords in the block is zero.
  713.  
  714.  Checksum for hard disk RigidDiskBlocks can be calculated with:
  715.  = <addr> $100 $08
  716.  
  717.  
  718. #  -- Corrects bootblock checksum
  719.  Usage:
  720.   # <addr> -- if there is a disk bootblock (2 disk blocks, 1024 bytes) read
  721.  into memory at <addr>, calculates a new checksum for the bootblock and stores
  722.  it in the bootblock (in memory). Displays old and new checksums.
  723.  Addr must be even.
  724.  
  725.  Extended usage: # <addr> <len> <offs>
  726.  where <len> is block length to be checksummed and <offs> is the offset
  727.  of the checksum longword from the start of the block. The checksum is
  728.  calculated to that the sum of the longwords with carry in the block
  729.  is $ffffffff.
  730.  
  731.  Checksum for pre-2.0 kickstart images can be calculated with:
  732.  # <addr> $40000 $3ffe8
  733.  and for 2.0 kickstart images with:
  734.  # <addr> $80000 $7ffe8
  735.  
  736. !  -- Play digisound
  737.  Usage:
  738.   ! <addr> <length> <period> [<count>]
  739.  Plays sound <length> bytes starting at <addr> and using sampling period
  740.  <period>. the sound repeats <count> times or until you stop it by
  741.  pressing Ctrl-C. <addr> must be in CHIP memory!.
  742.  
  743. cls -- Clears the monitor window
  744.  
  745. del <filename> -- Deletes a file
  746.  
  747. cd  <dirname>  -- Sets the current directory
  748.  
  749. dir [<name>]   -- Displays the directory
  750.   if you don't specify the name, then current directory
  751.   will be displayed.
  752.  
  753. \ -- Command/ New Shell
  754.   Usage:
  755.    \ shell_command  -- executes one shell command
  756.    \                -- starts new shell with `NewShell' or `NewCLI'
  757.   This uses the AmigaDOS Execute() call on 1.3, so it requires the `Run'-
  758.   command to be in the C:-directory in AmigaDOS versions before 1.3.2
  759.   (on AmigaDOS 2.0 it uses the new System() call)
  760.  
  761. vt -- show tasks
  762.   Shows the addresses, types, states and priorities of all tasks currently
  763.   in the system (on the exec TaskWait & TaskReady lists and the current task)
  764.  
  765.   Type: t - task, p - process, c - CLI process
  766.   State: w - waiting, r - ready, c - current
  767.  
  768. vl -- show library list
  769.   Shows the addresses, names, versions & revisions and open counts of
  770.   all libraries on the exec library list.
  771.  
  772. vd -- show device list
  773.   Shows the addresses, names, versions & revisions and open counts of
  774.   all devices on the exec device list.
  775.  
  776. vr -- show resource list
  777.   Shows the addresses and names of all resources on the exec resource list.
  778.  
  779. vp -- show port list
  780.   Shows the addresses, SigBits, mp_Flags-fields and names of all public
  781.   message ports currently in the system (Note: the flags-field is not
  782.   in hexadecimal, it was in decimal in previous versions)
  783.  
  784. vs -- show semaphore list
  785.   Shows the addresses and names of all public SignalSemaphores currently
  786.   in the system.
  787.  
  788. ve -- show autoconfig device list
  789.   Lists information about the autoconfig boards/devices in the system.
  790.   The ConfigDev structure address, board hardware address, manufacturer and
  791.   product numbers, size of board in KBytes and cd_Flags/er_Flags values
  792.   are shown. The ConfigDev and board addresses and the flags are in
  793.   hexadecimal, the other numbers are in decimal.
  794.  
  795. echo -- display text and/or numbers
  796.   Usage:
  797.     echo string | [$][expr] [string | [$][expr] ...]
  798.  
  799.   Writes the string(s) given in the command to the monitor output window/file.
  800.   strings can be quoted with double quotes. Also, the `\'-character is used
  801.   as an escape character. The following escape sequences are available:
  802.  
  803.    \n -> newline/linefeed
  804.    \r -> carriage return
  805.    \t -> tabulator
  806.    \e -> the ASCII Escape character (0x1b, 27 decimal)
  807.    \\ -> `\'
  808.    \xnn where nn are hex digits -> ascii code nn
  809.  
  810.   These escape sequences can also be used whenever file names are given
  811.   to the monitor.
  812.  
  813.   Numbers/expressions can be output by putting them in square brackets.
  814.   [expr]  -- displays expression in decimal
  815.   $[expr] -- displays expression in hexadecimal
  816.  
  817.   The echo-command is most useful in script files.
  818.  
  819. exec -- execute a script file
  820.   Usage:
  821.     exec filename
  822.  
  823.   Executes the given script file. for more information, see `Scripts' below.
  824.  
  825. poke, pokew, pokel  --  write to memory
  826.  
  827.   poke <addr> <byteval>
  828.   pokew <addr> <wordval>
  829.   pokel <addr> <longval>
  830.  
  831.   Similator to corresponding BASIC commands. These commands write data to
  832.   a memory location. Poke writes a byte (8-bit), pokew writes a word (16-bit)
  833.   and pokel writes a longword (32-bit). Note that there is no comma between
  834.   the address and value parameters.
  835.  
  836. x -- Exit
  837.   Cleanup and exit the monitor. This frees all the memory allocated
  838.   with ( and & commands and closes redirection file, if open.
  839.  
  840.  
  841. Scripts
  842. -------
  843.  
  844.   The Amiga monitor versions 1.52 and above has a built-in script language.
  845.   All normal monitor commands can be executed from scripts, and the are
  846.   additional commands for controlling script execution.
  847.   Scripts are started with the `exec' command that can also be used inside
  848.   scripts, so scripts can be nested (and memory availability is the only
  849.   limit of the nesting depth).
  850.  
  851.   All lines in a script file beginning with a semicolon (;) are treated as
  852.   comments and ignored by the monitor.
  853.  
  854. Script control commands
  855. -----------------------
  856.  
  857. quit -- quit executing a script and return to the previous script or
  858.         keyboard input.
  859.  
  860. goto label  --  go to a specified label in a script.
  861.         Labels must be in the beginning of a line, and begin with a period (.)
  862.         An optional colon can be in the end of the label name. The period
  863.         and colon are not actually parts of the label name, so they are
  864.         not included in the goto-command.
  865.  
  866.  Example:
  867.  
  868.    goto foobar
  869.    ... other script commands
  870.  
  871. .foobar:    echo "This is the label `foobar'"
  872.  
  873. if <expr> <command> -- conditional execution
  874.         Executes the single <command> only when expression <expr> is non-zero.
  875.         More complex conditionals can be constructed by using if and goto
  876.         together.
  877.  
  878.   Example:
  879.  
  880. set counter = 1
  881. .loop
  882. echo "counter is" [counter]
  883. set counter=counter+1
  884. if counter <= _10 goto loop
  885.  
  886. Version history:
  887. ----------------
  888. 1.59 ->
  889.  - added 've'-command (list autoconfig devices)
  890.  - 'no auto stackreset'-option flag and 'rs'-command to reset
  891.    the stack pointer
  892.  - automatically initializes a0/d0 to point to an empty
  893.    command line when 'l'-command is used to load a new executable file.
  894.  
  895. 1.58 ->
  896.  - changed window position/size logic. now monitor window should
  897.    open to the visible part of a bigger-than-display screen.
  898.  
  899. 1.57 ->
  900.  - memory display displays only the requested memory block
  901.    (the last line is not always full)
  902.  
  903. 1.56 ->
  904.  - memory display stops at end of hunk (disassembly already did that)
  905.  - memory allocation error now stops script execution
  906.  - added %s and %x formats to the mf-command
  907.  
  908. 1.55 ->
  909.  - uses TC_TrapData instead of TC_UserData again...
  910.  - now the `(' command cannot allocate negative amounts of memory...
  911.  - now the assembler understands `.b' as short branch specifier and
  912.    `.w' as long branch specifier.
  913.  - now frees memory properly in `u' command.
  914.  
  915. 1.54 ->
  916.  - added poke[w,l] commands
  917.  
  918. 1.53 ->
  919.  - better error reporting with scripts.
  920.  
  921. 1.52 ->
  922.  - scripts (exec/quit/if/goto/echo commands)
  923.  - \-command can be used to execute any cli/shell command.
  924.  
  925. 1.51 ->
  926.  - no longer lists bss hunks as split in strange ways (one lsl.l #2,d0 was
  927.    missing in version 1.50)
  928.  
  929. 1.50 ->
  930.  - now mf-command requires space after command, else -> m fxxxx
  931.  - show seglist displays info about split data/bss hunks
  932.  - internal source reorganization
  933.  
  934. 1.49 ->
  935.  - hunk type display also shows chip/fast
  936.  - some changes in symbol handling
  937.  - internal source reorganization
  938.  - disassembly stops at hunk end
  939.  
  940. 1.48 ->
  941.  - address register relative symbol support (rb-command)
  942.  
  943. 1.47 ->
  944.  - symbol support
  945.  - variables now case sensitive
  946.  - hunk type display in `sl'-command
  947.  
  948. 1.46 ->
  949.  - added breakpoint counts.
  950.  
  951. 1.45 ->
  952.  - small change in help text.
  953. 1.44 ->
  954.  - added task/library/device/resource/port/semaphore list viewing commands.
  955.  
  956. 1.43 ->
  957.  - added formatted memory dump command
  958.  - now gives error message if cannot allocate audio channels in digisound
  959.    play command.
  960.  - display can be stopped/started with ctrl-s/ctrl-q
  961.  - spaces can be used in `set register' command before the equal sign.
  962.  
  963. 1.42 ->
  964.  - better option handling
  965.  - understands 2.0 shell window close gadget
  966.  - redirection to file now appends if possible
  967.  - modulo operator now `%'
  968.  
  969. 1.41 ->
  970.  - fixed a bug that prevented some assembler instructions working.
  971.  
  972. 1.40 ->
  973.  - cd works correctly again
  974.    (in 1.37..1.39 it ignored first letter of dir name...)
  975.  
  976. 1.39 ->
  977.  - interrupting `c' or `h' commands no longer causes error conditions.
  978.  - added option flag 2 to select whether characters $a0-$ff are printable
  979.    in `m' command memory dump.
  980.  
  981. 1.38 ->
  982.  - return from `j' or `g' commands with rts now works (was a major bug in 1.37)
  983.  - input routine no longer acts strangely if shift-cursor-down
  984.    or ESC-cursor/function/help is pressed.
  985.  - command line automatically set if file name given on the monitor command
  986.    line.
  987.  - many little changes in assembler. most of these not visible to the user.
  988.  
  989. 1.37 -> lots of new features...
  990.  - major source code reorganization
  991.  - extended checksum commands
  992.  - calculator `ascii' output
  993.  - memoryinfo displays hunk offsets
  994.  - breakpoint numbers
  995.  - added `port()' to expression parser
  996.  
  997. 1.34 ->
  998.  - added `narrow disassembly' option.
  999.  - digisound player now defaults to play the sample once.
  1000.  
  1001. 1.32 ->
  1002.  - now opens own window only if started with `run' or window width and
  1003.    height are given on the command line. can be used from serial terminal
  1004.    with AUX: shell.
  1005.  
  1006. 1.31 ->
  1007.  - it is now not possible to accidentally try to assemble code to
  1008.    an odd address.
  1009.  
  1010. 1.30 ->
  1011.  - many internal changes: global variable base register changed, uses
  1012.    new library call macros...
  1013.  
  1014. 1.29 ->
  1015.  - added lib(), dev(), res() and task() to expression parser.
  1016.  
  1017. 1.28 ->
  1018.  - modified patchtrace to work also when vector base is relocated.
  1019.  - small changes in initial window placement and size
  1020.  
  1021. 1.27 ->
  1022.  - disk block/bootblock checksum functions and jump/go/trace etc. now
  1023.    check properly for odd addresses.
  1024.  - `odd address'-error message
  1025.  - skip instruction-command
  1026.  - Exit() now returns control back to the monitor.
  1027.  
  1028. 1.26 ->
  1029.  - added hend() and nhunks-functions to the expression parser.
  1030.  - added command line options for window width and height
  1031.  - a file name to LoadSeg() can be given in the command line
  1032.  - new filename parse routine, now names with spaces in
  1033.    them must be in quotes
  1034.  
  1035. 1.25 ->
  1036.  - (internal change) now uses TC_Userdata instead of TC_TrapData because
  1037.    TC_TrapData is marked as private in some prerelease 1.4/2.0 includes.
  1038.  - `\'-command now first tries to start a shell, then a CLI.
  1039.  - disk read/write commands can be used with hard disks etc.
  1040.  - fixed condition code register setting with go and jump commands.
  1041.  
  1042. 1.24 ->
  1043.  - corrected a small bug in the assembler/disassembler mnemonic tables
  1044.    (trap and tas-instructions were accidentally exchanged...)
  1045.  
  1046. 1.23 ->
  1047.  - quicktrace-command
  1048.  - now reserves separate areas of stack for the monitor itself and
  1049.    the program being debugged.
  1050.  
  1051. 1.22 ->
  1052.  - better handling of stack pointer with jump & go-commands
  1053.  - extended trace command
  1054.  - memory display can be used at odd addresses
  1055.  - generally cleaned up the source code
  1056.  - variables are now case-insensitive.
  1057.  
  1058. 1.20 ->
  1059.  - added the `[register]'-syntax in the expression parser
  1060.  
  1061. 1.19 ->
  1062.  - disassembler now uses new routines. this makes the monitor
  1063.    executable little smaller than 1.17
  1064.  
  1065. 1.17 ->
  1066.  - monitor is now re-entrant and can be made resident
  1067.  - transfer no longer crashes if you transfer from location zero
  1068.  - default base is again hexadecimal
  1069.  
  1070. 1.15 ->
  1071.  - some minor bug fixes in assembler
  1072.    (move sp,usp or exg Rx,sp did not work)
  1073.  - `memory info'-command
  1074.  - underscores are allowed in variable names
  1075.  - variable list is kept in alphabetical order
  1076.  
  1077. 1.12 ->
  1078.  - expressions can now be used instead of numbers. also included
  1079.    calculator-command.
  1080.  - variables can be used in expressions.
  1081.  - user-defineable default number base, default is now decimal.
  1082.  - hunt-command no longer finds anything in the monitor code/data areas
  1083.  - show seglist now displays hunk numbers
  1084.  - chip memory allocation syntax has been changed.
  1085.  
  1086. 1.08 ->
  1087.  - the monitor works ok with 68010/68020 processors. previous versions
  1088.    left sometimes extra data in supervisor stack.
  1089.  
  1090. 1.07 ->
  1091.  - The disassembler and assembler handle exg Dn,An correctly
  1092.    (previously the data and address register numbers were reversed)
  1093.  - The disassembler no more displays any invalid codes as valid
  1094.    instructions (On the 68000 processor, of course. The monitor does
  1095.    not currently support 68010/68020 extra instructions).
  1096.  - The pc-relative indexed addressing mode now works with the assembler.
  1097.  - Some little bugs were fixed in the assembler.
  1098.     + And/or-instructions work with a pc-relative source operand. 
  1099.     + cmpm works with all sizes
  1100.     + most(if not all...) of the bugs that caused the assembler to
  1101.       assemble invalid instructions have been fixed.
  1102.  - `sp' can be used instead of `a7' in the assembler and the disassmbler
  1103.    displays a7 as `sp'.
  1104.  - The assembler now unserstands blo/bhs, slo/shs and dblo/sbhs
  1105.    and assembles them as bcs/bcc, scs/scc and dbcs/dbcc
  1106.  - The disassembler displays address-register relative offsets and short
  1107.    absolute addresses as signed numbers.
  1108.  - The monitor works now better with 60-column default font (TOPAZ60).
  1109.  - Disk read/write commands can be used with non-chip memory
  1110.  - Play digisound command has an optional parameter to specify
  1111.    how many times the sample is played.
  1112.  - A new command has been added to specify a command line for programs
  1113.    executed under the control of the monitor.
  1114.  - Breakpoints work even if you jump into the code at to breakpoint.
  1115.    The breakpoint does not activate until the instruction at the break
  1116.    position is executed, so you don't get immediately interrupted.
  1117.    (internally the monitor uses the trace-exception to skip the breakpoint
  1118.    at the first time...)
  1119.  
  1120. 1.06 and older...
  1121.  - prehistoric versions...
  1122.  
  1123.  
  1124.   Amiga Monitor v1.59 Copyright ⌐ 1987-1993 by Timo Rossi. The monitor
  1125. can be freely distributed non-commercially. This document file and the
  1126. `patchtrace'-program should be included in the distribution. Preferred
  1127. way of distribution is the lha-archive `mon159.lha'.
  1128.  
  1129.   Permission is given to Fred Fish to distribute this program
  1130. on his `Fish disks'.
  1131.  
  1132. Send suggestions, bug reports etc. to:
  1133.  
  1134.   Timo Rossi
  1135.   Mattilankatu 40 A 4                E-mail:
  1136.   40600 JyvΣskylΣ                 trossi@jyu.fi
  1137.   FINLAND
  1138.  
  1139.